package javabase.schoolwork.day6_5;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

/**
 * @author fance
 * @date 18-6-4 下午12:59
 */
public class RandomTeacher {
    public static String[] getRandomTeachers(String[] teachers,int n) {
        String[] res = new String[n];
        Set<Integer> set = new HashSet<>();
        Random random = new Random(47);
        while (set.size() < n) {
            set.add(random.nextInt(teachers.length));
        }
        int cnt = 0;
        for (Integer index : set) {
            res[cnt++] = teachers[index];
        }
        return res;
    }

}
